package com.yifan.xmlTool.util;

import com.yifan.xmlTool.annotation.IAttribute;
import com.yifan.xmlTool.annotation.IDocument;
import com.yifan.xmlTool.annotation.IElement;
import com.yifan.xmlTool.interfaces.IObject;
import com.yifan.xmlTool.interfaces.XML;
import com.yifan.xmlTool.interfaces.XMLObj;
import lombok.Data;
import org.dom4j.Element;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author YIFan
 * @Date 2021/3/1 17:36
 * @Version 1.0
 */
@IDocument(name = "MXML")
public class MXML extends XMLObj implements XML {

    // 所有元素
    @IElement(name = "Objects")
    public List<Element> objects = elements;

    // 根属性
    @IAttribute(name = "xmlns:xsi")
    public String schema = "http://www.w3.org/2001/XMLSchema-instance";

    // 根属性
    @IAttribute(name = "BizDomain")
    public String bizDomain = "2";

    @Override
    public void addObject(IObject obj) {
        objects.add(obj.toObject());
    }

    public List<Element> getObjects() {
        return objects;
    }

    public void setObjects(List<Element> objects) {
        this.objects = objects;
    }

    public String getSchema() {
        return schema;
    }

    public void setSchema(String schema) {
        this.schema = schema;
    }

    public String getBizDomain() {
        return bizDomain;
    }

    public void setBizDomain(String bizDomain) {
        this.bizDomain = bizDomain;
    }

}
